public class Sort {

    public static void sort(int[] nums) {
        for (int i = 1; i < nums.length; i++) {
            int n = nums[i];
            int j = i;
            for (; j > 0 && n < nums[j - 1]; j--) {
                nums[j] = nums[j - 1];
            }
            nums[j] = n;
        }
    }

    public static void main(String[] args) {
        int[] nums = {3, 5, 1, 2, 0};
        sort(nums);
        for (int i = 0; i < nums.length; i++) {
            System.out.print(nums[i] + " ");
        }
    }

}
